<template>
  <div class="company-container">
    <div class="company-search">
      <span class="page-title">企业列表</span>
      <el-input placeholder="请输入搜索内容" v-model="keyWords" class="input-with-select search-keyword">
        <el-select v-model="select" slot="prepend" placeholder="请选择">
          <el-option label="企业名称" value="1"></el-option>
        </el-select>
      </el-input>
      <el-button type="primary" size="small" icon="el-icon-search" @click="searchCompany">搜索</el-button>
      <el-button type="info" size="small" class="search-keyword-reset" plain @click="resetSearch">重置</el-button>
      <el-button type="success" size="small" icon="el-icon-plus" @click="handelAdd"
                 v-if="checkPermissionPoints(1) == 1">
        新增企业
      </el-button>
    </div>

    <!--企业table-->
    <div class="company-table">
      <el-table ref="multipleTable" :data="companyData" border stripe fit v-loading="listLoading"
                :row-style="{height:'50px'}" :header-row-style="{height:'40px'}">
        <el-table-column label="id" width="80">
          <template slot-scope="scope">
            {{scope.row.id}}
          </template>
        </el-table-column>
        <el-table-column label="企业名称" width="280" show-overflow-tooltip>
          <template slot-scope="scope">
            {{scope.row.mechanismName}}
          </template>
        </el-table-column>
        <el-table-column label="企业封面" width="120">
          <template slot-scope="scope">
            <img
              v-lazy="scope.row.mechanismUrl?scope.row.mechanismUrl:require('../../../assets/common_images/placeholder-pic.png')"
              class="company_pic" v-viewer/>
          </template>
        </el-table-column>
        <el-table-column label="企业地址" width="300" show-overflow-tooltip>
          <template slot-scope="scope">
            {{scope.row.mechanismAddress}}
          </template>
        </el-table-column>
        <el-table-column label="评分" width="135">
          <template slot-scope="scope">
            {{scope.row.mechanismScore}}
          </template>
        </el-table-column>
        <el-table-column label="是否隐藏" width="100">
          <template slot-scope="scope">
            {{scope.row.delStatus == 0?'显示':'隐藏'}}
          </template>
        </el-table-column>
        <el-table-column label="生成时间" width="160">
          <template slot-scope="scope">
            <span v-if="scope.row.time">{{ scope.row.time | formatTime}}</span>
          </template>
        </el-table-column>

        <el-table-column fixed="right" label="操作" min-width="200">
          <template slot-scope="{row}">
            <el-dropdown size="mini" :split-button="true" type="primary" @click="handleLook(row)"
                         v-if="checkPermissionPoints(3) == 1">查看
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="handleEdit(row)" v-if="checkPermissionPoints(4) == 1">编辑
                </el-dropdown-item>
                <el-dropdown-item @click.native="handleDelete(row)" v-if="checkPermissionPoints(2) == 1">删除
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :type="1" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit"
                  @pagination="getCompanyList"/>
    </div>

    <!--查看企业-->
    <el-dialog title="详情信息" :lock-scroll="true" :visible.sync="dialogLookVisible" width="960px" class="company-dialog"
               top="11vh">
      <el-form label-position="right" size="mini" label-width="auto" class="demo-table-expand">
        <el-form-item label="企业名称：">
          <span>{{lookCompany.mechanismName}}</span>
        </el-form-item>
        <el-form-item label="关键字：">
          <span>{{lookCompany.mechanismKey}}</span>
        </el-form-item>
        <el-form-item label="企业简介：">
          <span v-html="lookCompany.mechanismDetails"></span>
        </el-form-item>
        <el-form-item label="企业地址：">
          <span>{{lookCompany.mechanismAddress}}</span>
        </el-form-item>
        <el-form-item label="企业logo：">
          <div class="upload-tip-text">只能上传jpg/png文件，且不超过500kb（建议尺寸320*320）</div>
          <img
            v-lazy="lookCompany.mechanismLogo?lookCompany.mechanismLogo:require('../../../assets/common_images/placeholder-pic.png')"
            class="company-pic"/>
        </el-form-item>
        <el-form-item label="企业封面：">
          <div class="upload-tip-text">只能上传jpg/png文件，且不超过500kb（建议尺寸240*180）</div>
          <img
            v-lazy="lookCompany.mechanismUrl?lookCompany.mechanismUrl:require('../../../assets/common_images/placeholder-pic.png')"
            class="company-pic"/>
        </el-form-item>
        <el-form-item label="企业视频：">
          <div class="upload-tip-text">只能上传mp3/avi文件，且不超过10M</div>
          <div class="video-play-box" @click="playVideo(lookCompany.companyVideo)">
            <img
              v-lazy="(lookCompany.companyVideo + '?vframe/png/offset/0.001')?(lookCompany.companyVideo + '?vframe/png/offset/0.001'):require('../../../assets/common_images/play-video.png')"
              class="play-icon"/>
            <div class="video-play-con">
              <span class="video-url">{{lookCompany.companyVideo}}</span>
            </div>
          </div>
        </el-form-item>
        <el-form-item label="图片墙：">
          <div class="upload-tip-text">只能上传jpg/png文件，且不超过500kb，最多6张（建议尺寸750*560）</div>
          <div v-if="lookCompany.imageList && lookCompany.imageList.length >0">
            <img v-lazy="item" v-for="(item,k) in lookCompany.imageList" :key="k" class="company-pic">
          </div>
        </el-form-item>
        <el-form-item label="企业评分：">
          <span>{{lookCompany.mechanismScore}}</span>
        </el-form-item>
        <el-form-item label="面试坐标：">
          <span>经度：{{lookCompany.x}}</span><span class="coordinate-y">纬度：{{lookCompany.y}}</span>
        </el-form-item>
        <el-form-item label="允许借支金额：">
          <span>{{lookCompany.lendMoney}}</span>
        </el-form-item>
        <el-form-item label="预支类型：">
          <span>{{lookCompany.dayMoneyType | filterDayMoney}}</span>
        </el-form-item>
        <el-form-item label="是否隐藏：">
          <span>{{lookCompany.delStatus==0?'显示':'隐藏'}}</span>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button style="width: 96px" size="small" @click="dialogLookVisible = false">取消</el-button>
      </span>
    </el-dialog>

    <!--新增/编辑企业-->
    <el-dialog :title="textMap[dialogStatus]" :lock-scroll="true" :visible.sync="dialogEditVisible" width="960px"
               top="11vh"
               class="company-dialog" @close="cancelCompany">
      <div class="company-add-box">
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-position="right" size="medium" label-width="auto"
                 class="demo-ruleForm">
          <el-form-item label="企业名称:" prop="mechanismName">
            <el-input v-model="ruleForm.mechanismName" style="width: 640px;" placeholder="请输入企业名称"
                      :clearable="true"></el-input>
          </el-form-item>
          <el-form-item label="关键字:" prop="mechanismKey">
            <el-input v-model="ruleForm.mechanismKey" style="width: 640px" placeholder="例“工资很高|福利很好|环境好”"
                      :clearable="true"></el-input>
          </el-form-item>
          <el-form-item label="企业简介:" prop="mechanismDetails">
            <el-input type="textarea" v-model="ruleForm.mechanismDetails" :autosize="{ minRows: 4, maxRows: 6 }"
                      placeholder="请输入企业简介" style="width: 640px"></el-input>
          </el-form-item>
          <el-form-item label="企业地址:" prop="mechanismAddress">
            <el-input v-model="ruleForm.mechanismAddress" style="width: 640px;" placeholder="请输入企业地址"
                      :clearable="true"></el-input>
          </el-form-item>
          <el-form-item label="企业logo:" prop="mechanismLogo" ref="mechanismLogo">
            <span>只能上传jpg/png/jpeg文件，且不超过1M（建议尺寸320*320）</span>
            <el-upload :action="upload_qiniu_url" list-type="picture-card" :auto-upload="true"
                       :limit="1" accept="image/jpg,image/png,image/jpeg" :data="qiniuData" :file-list="fileList"
                       :before-upload="beforeImageUpload" :on-exceed="handleExceed" :on-remove="handleRemove"
                       :http-request="upQiniu">
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>


          <el-form-item label="企业封面:" prop="mechanismUrl" ref="mechanismUrl">
            <span>只能上传jpg/png/jpeg文件，且不超过1M（建议尺寸240*180）</span>
            <el-upload :action="upload_qiniu_url" list-type="picture-card" :auto-upload="true"
                       :limit="1" accept="image/jpg,image/png,image/jpeg" :data="qiniuData"
                       :before-upload="beforeImageUpload" :file-list="fileList2" :on-remove="handleRemove2"
                       :on-exceed="handleExceed"
                       :http-request="upQiniu2">
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>

          <el-form-item label="企业视频:" prop="companyVideo" ref="companyVideo">
            <span>只能上传mp4文件，且不超过10M</span>
            <el-upload :action="upload_qiniu_url" list-type="text" :auto-upload="true"
                       :limit="1" accept="audio/mp4,video/mp4" :data="qiniuData"
                       :before-upload="beforeImageUpload2" :file-list="fileList4" :on-remove="handleRemove4"
                       :on-exceed="handleExceed3" :http-request="upQiniu4">
              <el-button size="mini" type="primary">点击上传</el-button>
            </el-upload>
          </el-form-item>

          <el-form-item label="图片墙:" prop="pictureList" ref="pictureList">
            <span>只能上传jpg/png/jpeg文件，且不超过1M，最多6张（建议尺寸750*560）</span>
            <el-upload :action="upload_qiniu_url" list-type="picture-card" :auto-upload="true"
                       :limit="6" accept="image/jpg,image/png,image/jpeg" :data="qiniuData" :file-list="fileList3"
                       :before-upload="beforeImageUpload3" :on-exceed="handleExceed2" :on-remove="handleRemove3"
                       :on-success="uploadSuccess">
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>
          <el-form-item label="企业评分:" prop="mechanismScore">
            <el-input v-model="ruleForm.mechanismScore" style="width: 640px;" placeholder="请输入企业评分"
                      :clearable="true"></el-input>
          </el-form-item>
          <el-form-item label="面试坐标(经度):" prop="x">
            <el-input style="width: 640px;" placeholder="请输入经度" :clearable="true" v-model="ruleForm.x"></el-input>
          </el-form-item>
          <el-form-item label="面试坐标(纬度):" prop="y">
            <el-input style="width: 640px;" placeholder="请输入纬度" :clearable="true" v-model="ruleForm.y"></el-input>
          </el-form-item>
          <el-form-item label="允许借支金额:" prop="lendMoney">
            <el-input v-model="ruleForm.lendMoney" style="width: 640px;" placeholder="请输入允许借支的最高金额"
                      :clearable="true"></el-input>
          </el-form-item>
          <el-form-item label="预支类型:" prop="dayMoneyType">
            <el-radio-group v-model="ruleForm.dayMoneyType">
              <el-radio :label=0>借支</el-radio>
              <el-radio :label=1>日薪</el-radio>
              <el-radio :label=2>周薪</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="是否隐藏:" prop="delStatus">
            <el-radio-group v-model="ruleForm.delStatus">
              <el-radio :label=0>显示</el-radio>
              <el-radio :label=1>隐藏</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>

        <div class="company-opt-btn">
          <el-button type="success" size="small" class="opt-box" @click="saveCompany" :loading="sendLoad">保存</el-button>
          <el-button class="opt-box" size="small" @click="cancelCompany">取消</el-button>
        </div>
      </div>
    </el-dialog>


  </div>
</template>

<script>
  import Pagination from '@/components/Pagination';
  import {mapGetters} from 'vuex';
  import {permissionPoints} from '@/utils/permission';
  import {formatDate} from "@/utils";
  import {getQiniuToken} from "@/api/qiniu";
  import {getQiNiuUpToken} from "../../../api/user/user";
  import {
    addMechanism,
    deleteMechanism,
    getInitCompanyList,
    getMechanismDetail,
    modifyMechanism
  } from "../../../api/work/work";

  export default {
    name: "companyManage",
    computed: {
      ...mapGetters([
        'points'
      ])
    },
    data() {
      var checkPicWall = (rule, value, callback) => {
        if (this.fileList3.length == 0) {
          callback(new Error('请上传企业照片墙'));
        }
        callback();
      };
      return {
        listLoading: false,
        downloadLoading: false,
        keyWords: '',
        select: '1',
        dialogStatus: '',
        textMap: {
          update: '编辑企业',
          create: '新增企业'
        },
        companyData: [],
        lookCompany: {},
        total: 0,
        listQuery: {
          page: 1,
          limit: 20,
          mechanismName: '',
          delStatus: ''
        },
        dialogLookVisible: false,
        dialogEditVisible: false,
        ruleForm: {
          mechanismName: '',
          mechanismKey: '',
          mechanismDetails: '',
          mechanismAddress: '',
          mechanismLogo: '',
          mechanismUrl: '',
          companyVideo: '',
          imageList: '',
          mechanismScore: '',
          lendMoney: '',
          dayMoneyType: 0,
          delStatus: 0,
          x: 0,
          y: 0,
          id: '',
        },
        rules: {
          mechanismName: [
            {required: true, message: '请输入企业名称', trigger: 'blur'}
          ],
          mechanismKey: [
            {required: true, message: '请输入关键字', trigger: 'blur'}
          ],
          mechanismDetails: [
            {required: true, message: '请输入企业简介', trigger: 'blur'}
          ],
          mechanismAddress: [
            {required: true, message: '请输入企业地址', trigger: 'blur'}
          ],
          mechanismLogo: [
            {required: true, message: '请上传企业logo', trigger: 'change'}
          ],
          mechanismUrl: [
            {required: true, message: '请上传企业封面', trigger: 'change'}
          ],
          pictureList: [
            {required: true, validator: checkPicWall, trigger: 'change'}
          ],
          companyVideo: [
            {required: false, message: '请上传企业视频', trigger: 'change'}
          ],
          mechanismScore: [
            {required: true, message: '请输入企业评分', trigger: 'blur'}
          ],
          x: [
            {required: true, message: '请输入经度', trigger: 'blur'}
          ],
          y: [
            {required: true, message: '请输入纬度', trigger: 'blur'}
          ],
          lendMoney: [
            {required: true, message: '请输入允许借支的最高金额', trigger: 'blur'}
          ],
          dayMoneyType: [
            {required: true, message: '请选择预支类型', trigger: 'change'}
          ],
          delStatus: [
            {required: true, message: '请选择是否隐藏', trigger: 'change'}
          ],
        },
        upload_qiniu_url: "https://upload-z2.qiniup.com",
        upload_qiniu_addr: "http://pic.lanpin123.com/",
        qiniuData: {
          token: "",
          key: ''
        },
        fileList: [],
        fileList2: [],
        fileList3: [],
        fileList4: [],
        sendLoad: false
      }
    },
    created() {
      this.getCompanyList();

      getQiNiuUpToken().then((res) => {
        this.qiniuData.token = res.data;
      });
    },
    methods: {
      searchCompany() {//搜索
        if (this.keyWords == '' || this.keyWords == undefined) {
          return this.$message.info({message: '请输入搜索内容', duration: 1000});
        }
        this.listQuery.mechanismName = '';
        if (this.select == 1) {
          this.listQuery.mechanismName = this.keyWords;
        }
        this.listQuery.page = 1;
        this.getCompanyList();
      },
      resetSearch() {
        this.select = '1';
        this.keyWords = '';
        this.listQuery.mechanismName = '';
        this.getCompanyList();
      },
      playVideo(video) {
        window.open(video);
      },
      checkPermissionPoints(type) {
        let pointObj = this.points.companyManage;
        return permissionPoints(type, pointObj);
      },
      getCompanyList() {//获取企业列表
        this.listLoading = true;
        getInitCompanyList(this.listQuery).then((res) => {
          this.listLoading = false;
          let retObj = res;
          if (retObj.code == 0 && retObj.data != null) {
            const {items, totalRecord} = retObj.data;
            this.total = totalRecord;
            this.companyData = items;
          }
        }).catch(() => {
          this.listLoading = false;
        })
      },
      handleExceed() {
        this.$notify.warning({
          title: '警告',
          message: '一次只能上传一张图片',
          duration: 2000
        });
      },
      handleExceed2() {
        this.$notify.warning({
          title: '警告',
          message: '一次只能上传六张图片',
          duration: 2000
        });
      },
      handleExceed3() {
        this.$notify.warning({
          title: '警告',
          message: '一次只能上传一个视频',
          duration: 2000
        });
      },
      beforeImageUpload(file) {
        const limitType = file.type === 'image/png' || file.type === 'image/jpg' || file.type === 'image/jpeg';
        if (!limitType) {
          this.$notify.warning({
            title: '警告',
            message: '请上传格式为image/png,image/jpg,image/jpeg的图片'
          })
        }
        const limitSize = file.size / 1024 / 1024 / 1 < 1;
        if (!limitSize) {
          this.$notify.warning({
            title: '警告',
            message: '图片大小必须小于1M'
          })
        }
        return limitType && limitSize;
      },
      beforeImageUpload2(file) {
        const limitType = file.type === 'audio/mp4' || file.type === 'video/mp4';
        if (!limitType) {
          this.$notify.warning({
            title: '警告',
            message: '请上传格式为audio/mp4,video/mp4的视频'
          })
        }
        let limitSize = file.size / 1024 / 1024 / 10 < 10;
        if (!limitSize) {
          this.$notify.warning({
            title: '警告',
            message: '视频大小必须小于10M'
          })
        }
        return limitType && limitSize;
      },
      beforeImageUpload3(file) {
        let fileType = 'jpg';
        if (file.type === 'image/png') {
          fileType = 'png'
        } else if (file.type === 'image/jpeg') {
          fileType = 'jpeg'
        }
        this.qiniuData.key = `front-${formatDate(new Date(), 'yyyyMMddhhmmss')}${Math.floor(Math.random() * 100)}.${fileType}`;

        const limitType = file.type === 'image/png' || file.type === 'image/jpg' || file.type === 'image/jpeg';
        if (!limitType) {
          this.$notify.warning({
            title: '警告',
            message: '请上传格式为image/png,image/jpg,image/jpeg的图片'
          })
        }
        let limitSize = file.size / 1024 / 1024 / 1 < 1;
        if (!limitSize) {
          this.$notify.warning({
            title: '警告',
            message: '图片大小必须小于1M'
          })
        }
        return limitType && limitSize;
      },
      handleRemove() {
        this.ruleForm.mechanismLogo = '';
      },
      handleRemove2() {
        this.ruleForm.mechanismUrl = '';
      },
      handleRemove3(file) {
        this.fileList3 = this.fileList3.filter(item => file.uid !== item.uid);
      },
      uploadSuccess(res, file, fileList) {
        this.fileList3.push({
          uid: fileList[fileList.length - 1].uid,
          url: this.upload_qiniu_addr + fileList[fileList.length - 1].response.key
        });
      },
      handleRemove4() {
        this.ruleForm.companyVideo = '';
      },
      commonImageUpload(req, callback) {
        const config = {
          headers: {'Content-Type': 'multipart/form-data'}
        };
        let fileType = '';
        if (req.file.type === 'image/jpg') {
          fileType = 'jpg'
        } else if (req.file.type === 'image/png') {
          fileType = 'png'
        } else if (req.file.type === 'image/jpeg') {
          fileType = 'jpeg'
        } else if (req.file.type === 'audio/mp4' || req.file.type === 'video/mp4') {
          fileType = 'mp4'
        }
        const key = `front-${formatDate(new Date(), 'yyyyMMddhhmmss')}${Math.floor(Math.random() * 100)}.${fileType}`;

        const fd = new FormData();
        fd.append('file', req.file);
        fd.append('token', this.qiniuData.token);
        fd.append('key', key);
        this.axios.post(this.upload_qiniu_url, fd, config).then(res => {
          callback(res);
        });
      },
      upQiniu(req) {
        this.commonImageUpload(req, (res) => {
          if (!res.data.key) {
            this.$message.error({message: '企业logo上传失败,请重新上传', duration: 2000});
            return;
          } else {
            this.ruleForm.mechanismLogo = this.upload_qiniu_addr + res.data.key;
            this.$refs['mechanismLogo'].clearValidate();
          }
        })
      },
      upQiniu2(req) {
        this.commonImageUpload(req, (res) => {
          if (!res.data.key) {
            this.$message.error({message: '企业封面上传失败,请重新上传', duration: 2000});
            return;
          } else {
            this.ruleForm.mechanismUrl = this.upload_qiniu_addr + res.data.key;
            this.$refs['mechanismUrl'].clearValidate();
          }
        })
      },
      upQiniu3(req) {
        this.commonImageUpload(req, (res) => {
          if (!res.data.key) {
            this.$message.error({message: '图片墙上传失败,请重新上传', duration: 2000});
            return;
          } else {
            this.fileList3.push({url: this.upload_qiniu_addr + res.data.key});
            this.$refs['pictureList'].clearValidate();
          }
        })
      },
      upQiniu4(req) {
        this.commonImageUpload(req, (res) => {
          if (!res.data.key) {
            this.$message.error({message: '企业视频上传失败,请重新上传', duration: 2000});
            return;
          } else {
            this.ruleForm.companyVideo = this.upload_qiniu_addr + res.data.key;
            this.$refs['companyVideo'].clearValidate();
          }
        })
      },
      handelAdd() {//新增
        this.dialogStatus = 'create';
        this.dialogEditVisible = true;
      },
      saveCompany() {//保存
        let temp = [];
        temp.push(this.ruleForm.companyVideo);
        if (this.fileList3.length > 0) {
          this.fileList3.map((item) => {
            temp.push(item.url);
          });
        }
        this.ruleForm.imageList = temp.join(';');

        if (this.dialogStatus == 'create') {
          this.$refs.ruleForm.validate((valid) => {
            if (valid) {
              this.sendLoad = true;
              this.saveMechanism();
            } else {
              return false;
            }
          });
        } else {
          this.$refs.ruleForm.validate((valid) => {//修改
            if (valid) {
              this.sendLoad = true;
              this.updateMechanism();
            } else {
              return false;
            }
          });
        }
      },
      saveMechanism() {
        addMechanism(this.ruleForm).then((res) => {//新增
          let retObj = res;
          this.sendLoad = false;
          if (retObj.code == 0 && retObj.data == 1) {
            this.dialogEditVisible = false;
            this.fileList = [];
            this.fileList2 = [];
            this.fileList3 = [];
            this.fileList4 = [];
            this.$refs.ruleForm.resetFields();
            this.$message.success({message: '新增企业成功', duration: 2000});
            this.getCompanyList();
          } else {
            this.$message.error({message: '新增企业失败，请重试', duration: 2000});
          }
        }).catch(() => {
          this.sendLoad = false;
        })
      },
      updateMechanism() {
        modifyMechanism(this.ruleForm).then((res) => {//新增
          let retObj = res;
          this.sendLoad = false;
          if (retObj.code == 0 && retObj.data == 1) {
            this.dialogEditVisible = false;
            this.fileList = [];
            this.fileList2 = [];
            this.fileList3 = [];
            this.fileList4 = [];
            this.$refs.ruleForm.resetFields();
            this.$message.success({message: '修改企业成功', duration: 2000});
            this.getCompanyList();
          } else {
            this.$message.error({message: '修改企业失败，请重试', duration: 2000});
          }
        }).catch(() => {
          this.sendLoad = false;
        })
      },
      handleLook(row) {//详细信息
        this.dialogLookVisible = true;
        getMechanismDetail(row.id).then((res) => {
          let retObj = res;
          if (retObj.code == 0 && retObj.data != null) {
            this.lookCompany = retObj.data;
            let array = retObj.data.imageList ? retObj.data.imageList.split(";") : [];
            if (array.length > 0) {
              let temp = [];
              for (let i = 0; i < array.length; i++) {
                if (i == 0) {
                  this.lookCompany.companyVideo = array[i];
                } else {
                  temp.push(array[i]);
                }
              }
              this.lookCompany.imageList = temp;
            }
          }
        })
      },
      handleEdit(row) {//编辑
        this.dialogStatus = 'update';
        this.dialogEditVisible = true;
        getMechanismDetail(row.id).then((res) => {
          let retObj = res;
          if (retObj.code == 0 && retObj.data != null) {
            this.ruleForm = retObj.data;
            this.fileList.push({'url': retObj.data.mechanismLogo});
            this.fileList2.push({'url': retObj.data.mechanismUrl});
            let video = '';
            let tempList = retObj.data.imageList.split(';');
            for (let index in tempList) {
              if (index == 0) {
                video = tempList[index];
                this.fileList4.push({'name': tempList[index], 'url': tempList[index]});
              } else {
                this.fileList3.push({'url': tempList[index]});
              }
            }
            this.ruleForm.companyVideo = video;
          }
        })
      },
      cancelCompany() {
        this.dialogEditVisible = false;
        this.fileList = [];
        this.fileList2 = [];
        this.fileList3 = [];
        this.fileList4 = [];
        this.$refs.ruleForm.resetFields();
      },
      handleDelete(row) {//删除
        this.$confirm('此操作将删除该企业, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteMechanism(row.id).then((res) => {
            let retObj = res;
            if (retObj.code == 0 && retObj.data > 0) {
              this.$message.success({message: '删除该企业成功', duration: 2000});
              this.getCompanyList();
            } else {
              this.$message.error({message: '删除该企业失败，请重试', duration: 2000});
            }
          })
        }).catch((err) => {
        });
      }
    },
    filters: {
      formatTime(time) {
        let date = new Date(time);
        return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
      },
      filterDayMoney(type) {
        if (type == 0) {
          return '借支';
        } else if (type == 1) {
          return '日薪';
        } else if (type == 2) {
          return '周薪'
        }
      }
    },
    components: {
      Pagination,
    }
  }
</script>

<style lang="scss" scoped>
  .company-container {
    .company-search {
      display: flex;
      align-items: center;
      width: 100%;
      height: 80px;
      .page-title {
        padding-left: 18px;
        font-size: 18px;
        font-weight: bold;
        min-width: 120px;
        text-align: left;
        color: rgba(61, 68, 77, 1);
      }
      .search-keyword {
        margin-right: 24px;
        width: 470px;
        > > > .el-select .el-input {
          width: 110px;
        }
        > > > .el-input-group__prepend {
          background-color: #fff;
        }
      }
      .search-keyword-reset {
        margin-right: 36px;
      }
    }
    .company-table {
      width: 98%;
      margin-left: 18px;
      > > > .el-table td, .el-table th {
        padding: 6px 0px;
      }
      > > > .el-table__header th {
        padding: 0;
        height: 30px;
        line-height: 30px;
      }
      > > > .el-table__fixed-right {
        height: 100% !important;
      }
      > > > .el-table__column-filter-trigger {
        line-height: 28px;
        i {
          font-size: 18px;
        }
      }
      > > > .el-table__row .cell {
        display: flex;
        align-items: center;
      }
      > > > .el-table__header .has-gutter .cell {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .company_pic {
        margin-left: 5px;
        object-fit: cover;
        border-radius: 2px;
        width: 40px;
        height: 40px;
      }
    }
    .company-dialog > > > .el-dialog .el-dialog__header {
      display: flex;
      align-items: center;
      height: 48px;
      background: #F7F8FA;
      padding: 0px 0px 0px 12px;
      position: fixed;
      width: 960px;
      z-index: 999;
      .el-dialog__headerbtn {
        top: 15px;
      }
    }
    .company-dialog .company-add-box {
      > > > .el-input--medium .el-input__inner {
        background: #F7F8FA;
      }
      > > > .el-input--medium .el-textarea__inner {
        background: #F7F8FA;
      }
    }
    .company-dialog > > > .el-dialog {
      overflow-y: auto;
      height: 80%;
    }
    .company-dialog > > > .el-dialog .el-dialog__body {
      margin-top: 48px;
    }
    .upload-tip-text {
      color: #ABADB3;
    }
    .video-play-box {
      width: 360px;
      height: 90px;
      display: flex;
      align-items: center;
      border: 1px solid #D8DCE5;
      border-radius: 2px;
      cursor: pointer;
      .play-icon {
        width: 72px;
        height: 72px;
        margin-left: 10px;
        margin-right: 10px;
        border-radius: 4px;
      }
      .video-play-con {
        display: flex;
        flex-direction: column;
        font-size: 13px;
        .video-text {
          color: #606266;
        }
        .video-url {
          color: #ABADB3;
        }
      }
    }
    .company-opt-btn {
      text-align: right;
      .opt-box {
        width: 96px;
      }
    }
    .company-pic {
      width: 120px;
      height: 120px;
      border-radius: 4px;
      margin-right: 4px;
    }
    .coordinate-y {
      margin-left: 30px;
    }
    > > > .el-button {
      line-height: 1.2;
    }
  }
</style>
